<template>
  <div :class="className" :style="{height:height,width:width}" />
</template>

<script>
import echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'


export default {
  mixins: [resize],
  props: {
    className: {
      type: String,
      default: 'chart'
    },
    width: {
      type: String,
      default: '100%'
    },
    height: {
      type: String,
      default: '300px'
    }
  },
  data() {
    return {
      chart: null
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart()
    })
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$el, 'macarons')

      this.chart.setOption({
        title: {
    text: '' //预设位置不够
  },
  legend: {  //统计每张table发生的订单数量用orderId来统计
    data: ['Preconceived Amount', 'Actual Amount']
  },
  radar: {
    // shape: 'circle',
    indicator: [
      { name: 'table001', max: 6500 },
      { name: 'table002', max: 16000 },
      { name: 'table003', max: 30000 },
      { name: 'table004', max: 38000 },
      { name: 'table005', max: 52000 },
      { name: 'table006', max: 25000 }
    ]
  },
  series: [
    {
      name: 'Budget vs spending',
      type: 'radar',
      data: [
        {
          value: [4200, 3000, 20000, 35000, 50000, 18000],
          name: 'Preconceived Amount'
        },
        {
          value: [5000, 14000, 28000, 26000, 42000, 21000],
          name: 'Actual Amount'
        }
      ]
    }
  ]
      })
    }
  }
}
</script>
